package com.ruoyi.statistics.controller;

import java.util.List;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.ruoyi.common.annotation.Log;
import com.ruoyi.common.core.controller.BaseController;
import com.ruoyi.common.core.domain.AjaxResult;
import com.ruoyi.common.enums.BusinessType;
import com.ruoyi.statistics.domain.LabStatisticsPerson;
import com.ruoyi.statistics.service.ILabStatisticsPersonService;
import com.ruoyi.common.utils.poi.ExcelUtil;
import com.ruoyi.common.core.page.TableDataInfo;

/**
 * 专任实验室人员Controller
 * 
 * @author jun.wang
 * @date 2022-05-21
 */
@RestController
@RequestMapping("/statistics/person")
public class LabStatisticsPersonController extends BaseController
{
    @Autowired
    private ILabStatisticsPersonService labStatisticsPersonService;

    /**
     * 查询专任实验室人员列表
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsPerson:list')")
    @GetMapping("/list")
    public TableDataInfo list(LabStatisticsPerson labStatisticsPerson)
    {
        startPage();
        List<LabStatisticsPerson> list = labStatisticsPersonService.selectLabStatisticsPersonList(labStatisticsPerson);
        return getDataTable(list);
    }

    /**
     * 导出专任实验室人员列表
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsPerson:export')")
    @Log(title = "专任实验室人员", businessType = BusinessType.EXPORT)
    @GetMapping("/export")
    public AjaxResult export(LabStatisticsPerson labStatisticsPerson)
    {
        List<LabStatisticsPerson> list = labStatisticsPersonService.selectLabStatisticsPersonList(labStatisticsPerson);
        ExcelUtil<LabStatisticsPerson> util = new ExcelUtil<LabStatisticsPerson>(LabStatisticsPerson.class);
        return util.exportExcel(list, "statisticsPerson");
    }

    /**
     * 获取专任实验室人员详细信息
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsPerson:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id)
    {
        return AjaxResult.success(labStatisticsPersonService.selectLabStatisticsPersonById(id));
    }

    /**
     * 新增专任实验室人员
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsPerson:add')")
    @Log(title = "专任实验室人员", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody LabStatisticsPerson labStatisticsPerson)
    {
        return toAjax(labStatisticsPersonService.insertLabStatisticsPerson(labStatisticsPerson));
    }

    /**
     * 修改专任实验室人员
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsPerson:edit')")
    @Log(title = "专任实验室人员", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody LabStatisticsPerson labStatisticsPerson)
    {
        return toAjax(labStatisticsPersonService.updateLabStatisticsPerson(labStatisticsPerson));
    }

    /**
     * 删除专任实验室人员
     */
//    @PreAuthorize("@ss.hasPermi('statistics:statisticsPerson:remove')")
    @Log(title = "专任实验室人员", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids)
    {
        return toAjax(labStatisticsPersonService.deleteLabStatisticsPersonByIds(ids));
    }
}
